home *** CD-ROM | disk | FTP | other *** search
/ Web Page Construction Kit 3.0 / Web Page Construction Kit 3.0.iso / pc / source / 3rdparty / java / jamba / dev / jambaobj.awx / TEMPLATE / TRBMPOBJ.JAVA < prev    next >
Encoding:
Text File  |  1996-07-15  |  6.9 KB  |  316 lines

  1. $$IF(JAMBA_EXPLCOMMENTS)
  2. /**
  3. * Jamba code template for $$JAMBA_CLASSNAME$$Obj
  4. * trbmpobj.java
  5. */
  6. $$ENDIF
  7.  
  8. // All Jamba objects are located in the objects package
  9. package Aimtech.objects;
  10.  
  11. // Standard Jamba imports
  12. import java.lang.*;
  13. import java.awt.*;
  14. import java.util.*;
  15. import Aimtech.utils.*;
  16. import Aimtech.effects.*;
  17. import Aimtech.smartpage.*;
  18.  
  19. $$IF(JAMBA_EXPLCOMMENTS)
  20. /**
  21. * Implementation of Jamba $$JAMBA_CLASSNAME$$Obj object
  22. */
  23. $$ENDIF
  24. public class $$JAMBA_CLASSNAME$$Obj extends BitmappedObj implements Runnable
  25. {
  26.     // This object's thread
  27.     Thread thread = null;
  28.  
  29.     // Used in objStart to check if previously stopped
  30.     private boolean bStopped = false;
  31.  
  32. $$IF(JAMBA_EXPLCOMMENTS)
  33.     /**
  34.     * Called once, and only once, when object is first loaded. Use
  35.     * to perform one time object initialization
  36.     */
  37. $$ENDIF
  38.     public void objLoad ()
  39.     {
  40. $$IF(JAMBA_TODOCOMMENTS)
  41.         //# TODO - Insert custom code here
  42. $$ENDIF
  43.         super.objLoad();
  44.     }
  45.  
  46. $$IF(JAMBA_EXPLCOMMENTS)
  47.     /**
  48.     * Called each time the Jamba page containing the object is displayed. Use
  49.     * to allocate object resources. These resources should be freed in
  50.     * objFlush
  51.     */
  52. $$ENDIF
  53.     public final void objPrepare()
  54.     {
  55. $$IF(JAMBA_TODOCOMMENTS)
  56.         //# TODO - Insert custom code here
  57. $$ENDIF
  58.         super.objPrepare();
  59.     }
  60.  
  61. $$IF(JAMBA_EXPLCOMMENTS)
  62.     /**
  63.     * Called each time the Jamba page containing the object is removed from
  64.     * the list of recently accessed Jamba pages. Use to free resources
  65.     * allocated by object.
  66.     */
  67. $$ENDIF
  68.     public void objFlush()
  69.     {
  70. $$IF(JAMBA_TODOCOMMENTS)
  71.         //# TODO - Insert custom code here
  72. $$ENDIF
  73.         super.objFlush();
  74.     }
  75.  
  76. $$IF(JAMBA_EXPLCOMMENTS)
  77.     /**
  78.     * Called in response to several events including the object being made
  79.     * visible and the HTML page containing the object being redisplayed.
  80.     */
  81. $$ENDIF
  82.     public void objStart()
  83.     {
  84.         // If object stopped by objStop(), restart it here
  85.         if (bStopped)
  86.         {
  87. $$IF(JAMBA_TODOCOMMENTS)
  88.             //# TODO - Insert custom code here
  89. $$ENDIF
  90.             // Start this object's thread
  91.             start ();
  92.             bStopped = false;
  93.         }
  94.  
  95.         super.objStart();
  96.     }
  97.  
  98. $$IF(JAMBA_EXPLCOMMENTS)
  99.     /**
  100.     * Called in response to several events including the object being made
  101.     * not visible and the HTML page containing the object being changed
  102.     * within a web browser such that another HTML page can be displayed.
  103.     * Use to cease any ongoing object activity.
  104.     */
  105. $$ENDIF
  106.     public void objStop()
  107.     {
  108.         if (!bStopped)
  109.         {
  110. $$IF(JAMBA_TODOCOMMENTS)
  111.             //# TODO - Insert custom code here
  112. $$ENDIF
  113.             // Stop the this object's thread
  114.             stop ();
  115.               bStopped = true;
  116.         }
  117.  
  118.         super.objStop();
  119.     }
  120.  
  121. $$IF(JAMBA_EXPLCOMMENTS)
  122.     /**
  123.     * Called to check if the object is dirty and needs to be repainted. This
  124.     * is used to minimize drawing of bitmapped objects.
  125.     */
  126. $$ENDIF
  127.     public synchronized boolean objNeedsPaint ()
  128.     {
  129. $$IF(JAMBA_TODOCOMMENTS)
  130.         //# TODO - Insert custom code here
  131. $$ENDIF
  132.         return (super.objNeedsPaint ());
  133.     }
  134.  
  135. $$IF(JAMBA_EXPLCOMMENTS)
  136.     /**
  137.     * Called when the object needs to repaint itself. The painting is done
  138.     * to an the offscreen bitmapped used for double-buffering.
  139.     */
  140. $$ENDIF
  141.     public synchronized void objPaint (Graphics g)
  142.     {
  143.         // Use local Graphics so as not to modify that passed in.
  144.         Graphics drawG = g.create();
  145.  
  146.         // Do common bitmapped object drawing
  147.         super.objPaint(g);
  148.  
  149.         // Clip to the geometry of the object
  150.         drawG.clipRect (geo.x,geo.y,geo.width,geo.height);
  151.  
  152. $$IF(JAMBA_TODOCOMMENTS)
  153.         //# TODO - Insert custom code here
  154. $$ENDIF
  155.         drawG.drawString ("Object Is Alive", geo.x + 10, geo.y + 20);
  156.  
  157.         // Allow local Graphics to be freed
  158.         drawG.dispose();
  159.  
  160.         // No longer need to be repainted
  161.         bNeedsPaint = false;
  162.     }
  163.  
  164. $$IF(JAMBA_EXPLCOMMENTS)
  165.     /**
  166.      * Called when object properties are set or changed
  167.      */
  168. $$ENDIF
  169.     public synchronized void objSetProp(String name, String value)
  170.     {
  171.         if (name.equals("property1"))
  172.         {
  173. $$IF(JAMBA_TODOCOMMENTS)
  174.             //# TODO - Insert custom code here
  175. $$ENDIF
  176.         }
  177.  
  178.         else if (name.equals("property2"))
  179.         {
  180. $$IF(JAMBA_TODOCOMMENTS)
  181.             //# TODO - Insert custom code here
  182. $$ENDIF
  183.         }
  184.  
  185.         // Default property handling
  186.         else super.objSetProp(name, value);
  187.  
  188.         // If a runtime property change force an update.
  189.         if (bPrepared)
  190.             objRepaint();
  191.     }
  192.  
  193. $$IF(JAMBA_EXPLCOMMENTS)
  194.     /**
  195.     * Called to retrieve the current value of an object property.
  196.     */
  197. $$ENDIF
  198.     public synchronized String objGetProp(String name)
  199.     {
  200.         // If object does not track a property value in member variables or
  201.         // does not modify properties without updating the object's property
  202.         // list, it can simply allow the default property handling to occur
  203.         // and not have a case for it in the following code
  204.         if (name.equals("property1"))
  205.         {
  206. $$IF(JAMBA_TODOCOMMENTS)
  207.             //# TODO - Insert custom code here
  208. $$ENDIF
  209.         }
  210.  
  211.         else if (name.equals("property2"))
  212.         {
  213. $$IF(JAMBA_TODOCOMMENTS)
  214.             //# TODO - Insert custom code here
  215. $$ENDIF
  216.         }
  217.  
  218.         return (super.objGetProp(name));
  219.     }
  220.  
  221. $$IF(JAMBA_EXPLCOMMENTS)
  222.     /**
  223.     * Called when an object methods has been called within a ToDo list.
  224.     */
  225. $$ENDIF
  226.     public synchronized boolean objDoMethod(String method, Vector args)
  227.     {
  228.         if (method.equals ("method1"))
  229.         {
  230. $$IF(JAMBA_TODOCOMMENTS)
  231.             //# TODO - Insert custom code here
  232. $$ENDIF
  233.         }
  234.         else if (method.equals ("method2"))
  235.         {
  236. $$IF(JAMBA_TODOCOMMENTS)
  237.             //# TODO - Insert custom code here
  238. $$ENDIF
  239.         }
  240.         else
  241.         {
  242.             return (super.objDoMethod(method, args));
  243.         }
  244.  
  245.         // Force an update
  246.         objRepaint();
  247.  
  248.         // The method was handled
  249.         return (true);
  250.     }
  251.  
  252. $$IF(JAMBA_EXPLCOMMENTS)
  253.     /**
  254.     * Called in response to mouse events to determine if the specified point is a
  255.     * hot spot on the object. This can be used by objects to make transparent pieces
  256.     * not active.
  257.     */
  258. $$ENDIF
  259.     public boolean objIsHotSpot (Point pt)
  260.     {
  261. $$IF(JAMBA_TODOCOMMENTS)
  262.         //# TODO - Insert custom code here
  263. $$ENDIF
  264.  
  265.         return (true);
  266.     }
  267.  
  268. $$IF(JAMBA_EXPLCOMMENTS)
  269.     /**
  270.     * Standard start method used by Jamba objects
  271.     */
  272. $$ENDIF
  273.     public void start ()
  274.     {
  275.         if (thread == null)
  276.         {
  277.             thread = new Thread (this);
  278.         }
  279.  
  280.         if (!thread.isAlive())
  281.         {
  282.             thread.start();
  283.         }
  284.     }
  285.  
  286. $$IF(JAMBA_EXPLCOMMENTS)
  287.     /**
  288.     * Standard stop method used by Jamba objects
  289.     */
  290. $$ENDIF
  291.     public void stop ()
  292.     {
  293.         if (thread != null)
  294.         {
  295.             Thread tmp = thread;
  296.             thread = null;
  297.             tmp.stop();
  298.         }
  299.     }
  300.  
  301. $$IF(JAMBA_EXPLCOMMENTS)
  302.     /**
  303.     * Object's run method for it's thread
  304.     */
  305. $$ENDIF
  306.     public void run ()
  307.     {
  308. $$IF(JAMBA_TODOCOMMENTS)
  309.         //# TODO - Insert custom code here
  310. $$ENDIF
  311.         // Must be last line in method
  312.         stop();
  313.     }
  314. }
  315.  
  316.